﻿using System.Diagnostics.Contracts;
using System.Text;

namespace OpenLS.Spreadsheet.Formats.Biff.OfficeArt
{
    class ComplexString
    {
        private readonly byte[] _data;

        public ComplexString(byte[] data)
        {
            Contract.Requires(data != null);
            this._data = data;
        }
        public static explicit operator string (ComplexString s)
        {
            return s.ToString();
        }
        public override string ToString()
        {
            Contract.Ensures(Contract.Result<string>() != null);
            Contract.Ensures(Contract.Result<string>().IndexOf('\0') == -1);
            Contract.Assert(_data != null);
            return Encoding.Unicode.GetString(_data).Replace("\0", "");
        }
        
    }
}